package common.code.mail;

import java.util.Properties;

import common.code.AppUtils;


public class SendMail {
	private static String mailServerHost;
	private static String mailServerPort;
	private static String fromAddress;   
    private static String password;  
    static{
		  Properties pros=AppUtils.loadProperties("/ApplicationConfig.properties");
		  mailServerHost=pros.getProperty("MAIL_SERVER_HOST");
		  mailServerPort=pros.getProperty("MAIL_SERVER_PORT");
		  fromAddress=pros.getProperty("FROM_ADDRESS");
		  password=pros.getProperty("MAIL_PASSWORD");
	}
    
	public static void sendMal(String toAddress,String emailSendMsg){
		MailSenderInfo mailInfo = new MailSenderInfo();   
	    mailInfo.setMailServerHost(mailServerHost);   
	    mailInfo.setMailServerPort(mailServerPort);   
	    mailInfo.setValidate(true);   
	    mailInfo.setUserName(fromAddress);   
	    mailInfo.setPassword(password);//您的邮箱密码   
	    mailInfo.setFromAddress(fromAddress);   
	    mailInfo.setToAddress(toAddress);   
	    mailInfo.setSubject("巡检任务通知：");   
	    mailInfo.setContent(emailSendMsg);
	    //这个类主要来发送邮件  
	    SimpleMailSender sms = new SimpleMailSender();  
	    //sms.sendTextMail(mailInfo);//发送文体格式   
	    sms.sendHtmlMail(mailInfo);//发送html格式 
	}
}